/**
 * Model package.
 */
package fr.umlv.m2.ig.model;

import java.util.LinkedList;
import java.util.List;

/**
 * This class defines a rail network line.
 * 
 * @author Gambouele Bertrand.
 * @author Viravout Alexandre.
 */
public class Line {

	/**
	 * The name of the line.
	 */
	private final String name;

	/**
	 * A list of journeys for this line.
	 */
	private final List<Journey> journeys = new LinkedList<Journey>();

	private double speed;

	/**
	 * Creates a {@code Line} object.
	 * This constructor can't be called out of the class package.
	 * Use the {@link LineBuilder} class to create a new object.
	 * 
	 * @param name the line name.
	 */
	Line(String name) {
		this.name = name;
		this.speed = 9.0;
	}

	/**
	 * Gets the name of the line.
	 * 
	 * @return the line name.
	 */
	public String getName() {
		return this.name;
	}

	/**
	 * Gets the list of journeys for this line.
	 * 
	 * @return the list of journeys.
	 */
	public List<Journey> getJourneys() {
		return this.journeys;
	}

	/**
	 * Adds a journey for this line.
	 * 
	 * @param journey the new journey to be added.
	 */
	void addJourney(Journey journey) {
		this.journeys.add(journey);
	}
	
	/**
	 * Sets train speed.
	 * 
	 * @param speed the speed.
	 */
	void setSpeed(double speed) {
	  this.speed = speed;
	}

	/**
	 * Returns trains speed for this line.
	 * @return trains speed for this line.
	 */
	public double getSpeed() {
		return this.speed;
	}

}